<HTML><HEAD><TITLE>module(+Module, ++Exports, ++Language)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Modules</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>module(+Module, ++Exports, ++Language)</H1>
Begin the definition of module Module, define some of its exports and the language it is written in.
<DL>
<DT><EM>Module</EM></DT>
<DD>Atom.
</DD>
<DT><EM>Exports</EM></DT>
<DD>A list of export specifications.
</DD>
<DT><EM>Language</EM></DT>
<DD>An atom or a list of atoms.
</DD>
</DL>
<H2>Description</H2>
   This is a directive that can occur only in a compiled file.  If Module
   is an existing module, it is first erased.  Then a new module is created
   and all subsequent definitions, declarations and directives are taken
   in the context of that new module.
<P>
   The list Exports must contain valid export specifications as
   described in export/1.  It defines the first part of the module's
   interface, subsequent export and reexport directives can add to that.
<P>
   Unlike with module/1, the new module does <EM>not</EM> implicitly import anything.
   In particular, no built-in predicates are available inside the module
   unless a language-module is specified in the Language argument.
   This module (or a list of them) is imported just after the new module
   is created.
<P>
   The main use of this feature is to write different parts of a program
   in different language dialects. For example, a module that contains code
   written in ISO-Prolog should be encapsulated in a module starting with:
<PRE>
	:- module(mymodule, [], iso).
</PRE>
   In this module, ISO language features can be used, but not (all)
   Eclipse features.
<P>
   The system does not allow the atom [] to be used as a module name!
   If [] is given as the Language argument, it indicates the empty list,
   rather than a module with name [].

<H3>Modes and Determinism</H3><UL>
<LI>module(+, ++, ++) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Module is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Module is not an atom, or Module is the atom [].
<DT><EM>(68) calling an undefined procedure </EM>
<DD>When called from Prolog.
<DT><EM>(82) trying to access a locked module </EM>
<DD>Module is locked.
</DL>
<H2>Examples</H2>
<PRE>
% A module in C-Prolog syntax:

     :- module(m, [p/1], cprolog).

     p("this is a list not a string").
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/modules/module-1.html">module / 1</A>, <A HREF="../../kernel/modules/create_module-1.html">create_module / 1</A>, <A HREF="../../kernel/modules/create_module-3.html">create_module / 3</A>, <A HREF="../../kernel/modules/erase_module-1.html">erase_module / 1</A>, <A HREF="../../kernel/modules/current_module-1.html">current_module / 1</A>, <A HREF="../../kernel/modules/export-1.html">export / 1</A>
</BODY></HTML>
